using System;
using System.Timers;

namespace sdom
{

public class Program
{
    public static void Main()
    {
        // Normally, the timer is declared at the class level, so
        // that it doesn't go out of scope when the method ends.
        // In this example, the timer is needed only while Main 
        // is executing. However, KeepAlive must be used at the
        // end of Main, to prevent the JIT compiler from allowing 
        // aggressive garbage collection to occur before Main 
        // ends.
        System.Timers.Timer aTimer = new System.Timers.Timer();
        //System.Timers.Timer aInfo = new System.Timers.Timer();

        // Hook up the Elapsed event for the timer.
        aTimer.Elapsed += new ElapsedEventHandler(OnTimedEventJob);

        // Set the Interval to 2 seconds (2000 milliseconds).
        aTimer.Interval = 1000*30;
        aTimer.Enabled = true;
 
        
        UpdateInventaryInfo();
        
        
        Console.WriteLine("Press the Enter key to exit the program.");
        Console.ReadLine();

        // Keep the timer alive until the end of Main.
        GC.KeepAlive(aTimer);
        
        
    }
 
    // Specify what you want to happen when the Elapsed event is 
    // raised.
    private static void OnTimedEventJob(object source, ElapsedEventArgs e)
    {
    	JobsClient c = new JobsClient();
    	Console.WriteLine("Llegint treballs");
    }
    
    
    // Specify what you want to happen when the Elapsed event is 
    // raised.
    private static void UpdateInventaryInfo()
    {

    	AddPCService addpc= new AddPCService();
    	if(addpc.addPC(SystemInfo.ComputerHash,SystemInfo.ComputerName,SystemInfo.UserDomainName,SystemInfo.OSName,SystemInfo.ComputerIP)=="OK")
			    Console.WriteLine("Inventary Info updated");		
    	else
    			Console.WriteLine("Inventary Error");
    	
    	
   
    }
}
}
 
